package com.aabte.design2.behavioral.iterator;

/**
 * @author Daniel
 * @version 1.0
 * @date 2020/5/3
 */
public class Application {

    private SocialNetwork network;
    private SocialSpammer spammer;

    public static void main(String[] args) {
        Application application = new Application();
        application.config();

        application.sendSpamToFriends(new Profile(1));
        application.sendSpamToCoworkers(new Profile(1));
    }

    public void sendSpamToFriends(Profile profile) {
        ProfileIterator iterator = network.createFriendsIterator(profile.getId());
        spammer.send(iterator, "非常重要的消息");
    }

    public void sendSpamToCoworkers(Profile profile) {
        ProfileIterator iterator = network.createCoworkersIterator(profile.getId());
        spammer.send(iterator, "非常重要的消息");
    }

    private void config() {
        this.network = new WeChat();
        this.spammer = new SocialSpammer();
    }

}
